package main.java.com.suncuicui.bi.FactoryMode.vo;

/**
 * Created by suncuicui on 2018/11/23.
 *
 */
public class SingletonAfterOptimization {

    /**私有构造方法，防止被实例化，（不完美之处，如果在构造函数中抛出异常，将永远得不到创建）*/
    private SingletonAfterOptimization() {}

    /**s使用一个内部类来维护单例*/
    private static class SinglrtonFactory{
        private static SingletonAfterOptimization instance = new SingletonAfterOptimization();
    }
    /** 获取实例 */
    public static SingletonAfterOptimization getInstance() {
        return SinglrtonFactory.instance;
    }
    /**如果该对象被用于序列化，可以保证对象在序列化前后保持一致 */
    public Object readResolve() {
        return getInstance();
    }
}
